package com.aco.party.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created by flying on 4/15/2016 0015.
 */
public class SpringContextUtil implements ApplicationContextAware {

    private static ApplicationContext applicationContext;//Spring应用上下文环境
    @Override
    public void setApplicationContext(ApplicationContext applicationcontext)
            throws BeansException {
        // TODO Auto-generated method stub
        SpringContextUtil.applicationContext=applicationcontext;
    }
    public static Object getBean(String name){
        return applicationContext.getBean(name);
    }
}
